import {NgModule}             from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {IndexComponent} from "./index/index.component";
import {LoginComponent} from "./login/login.component";
import {RegisterComponent} from "./register/register.component";
import {ArticleComponent} from "./article/article.component";
import {BackComponent} from "./back-stagemanagement/back.component";
import {BackItemArticleUploadComponent} from "./back-stagemanagement/back-stagemanagement-item/backitem-article-upload.component";
import {BackItemArticleManageComponent} from "./back-stagemanagement/back-stagemanagement-item/backitem-article-manage.component";
import {ActivityComponent} from "./activity/activity.component";
import {AuthGuard} from "./service/auth-guard.service";
import {AuthService} from "./service/auth.service";
import {BackItemActivityUploadComponent} from "./back-stagemanagement/back-stagemanagement-item/backitem-activity-upload.component";
import {BackItemActivityManageComponent} from "./back-stagemanagement/back-stagemanagement-item/backitem-activity-manage.component";
import {ArticleListComponent} from "./article/article-list.component";
import {ArticleService} from "./service/article.service";
import {ActivityService} from "./service/activity.service";
import {RetrievePasswordComponent} from "./retrieve-password/retrieve-password.component";
import {ChangePasswordComponent} from "./change-password/change-password.component";


const routes: Routes = [
    {path: '', redirectTo: '/index', pathMatch: 'full'},//默认的路由
    {path: 'index', component: IndexComponent},
    {path: 'login', component: LoginComponent},
    {path: 'register', component: RegisterComponent},
    {path: 'article/:id', component: ArticleComponent},
    {path: 'articleList', component: ArticleListComponent},
    {path: 'activity/:id', component: ActivityComponent},
    {path: 'retrievePassword/:token', component: ChangePasswordComponent},
    {path: 'retrievePassword', component: RetrievePasswordComponent},
    {path: 'back', canActivate: [AuthGuard], component: BackComponent, children:[
        {path: 'articleupload', component: BackItemArticleUploadComponent},
        {path: 'articlemanage', component: BackItemArticleManageComponent},
        {path: 'activityupload', component: BackItemActivityUploadComponent},
        {path: 'activitymanage', component: BackItemActivityManageComponent}
        ]},
    {path: '**', component: IndexComponent }

];
@NgModule({
    imports: [RouterModule.forRoot(routes)],
    exports: [RouterModule],
    providers: [
      AuthGuard,
      AuthService,
      ArticleService,
      ActivityService
    ]
})
export class AppRoutingModule {


}
